const string = `
.trunk * {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
.trunk *::after,
::before {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
.dunWrapper {
  margin-top: 16px;
}
@media screen and (max-width: 500px) {
  .dunWrapper {
    margin-top: 40px;
  }
}
.trunk {
  border: 10px solid black;
  height: 500px;
  width: 450px;
  position: relative;
  border-radius: 220px 220px 200px 200px;
}
@media screen and (max-width: 500px) {
  .trunk {
    border: 5px solid black;
    width: 220px;
    height: 250px;
    position: relative;
  }
}
.nose {
  width: 26px;
  height: 16px;
  background-color: black;
  position: absolute;
  left: 50%;
  transform: translateX(-13px);
  top: 180px;
  border-radius: 5px 5px 10px 10px;
}
@media screen and (max-width: 500px) {
  .nose {
    width: 14px;
    height: 8px;
    background-color: black;
    position: absolute;
    left: 50%;
    transform: translateX(-7px);
    top: 90px;
    border-radius: 2px 2px 5px 5px;
  }
}
.mouse {
  width: 40px;
  height: 10px;
  border: 1px solid black;
  background-color: red;
  position: absolute;
  left: 50%;
  transform: translateX(-20px);
  top: 210px;
  border-radius: 0 0 50% 50%;
}
@media screen and (max-width: 500px) {
  .mouse {
    width: 20px;
    height: 5px;
    border: 1px solid black;
    background-color: red;
    position: absolute;
    left: 50%;
    transform: translateX(-10px);
    top: 105px;
    border-radius: 0 0 50% 50%;
  }
}

.eye {
  width: 80px;
  height: 120px;
  background-color: black;
  position: relative;
  top: 100px;
  left: 100px;
  border-radius: 50%;
  transform: rotate(35deg);
}
@media screen and (max-width: 500px) {
  .eye {
    width: 40px;
    height: 60px;
    background-color: black;
    position: relative;
    top: 50px;
    left: 50px;
    border-radius: 50%;
    transform: rotate(35deg);
  }
}
.eye::before {
  content: "";
  display: block;
  width: 80px;
  height: 120px;
  background-color: black;
  position: absolute;
  border-radius: 50%;
  transform: rotate(-70deg);
  left: 130px;
  bottom: 90px;
}
@media screen and (max-width: 500px) {
  .eye::before {
    content: "";
    display: block;
    width: 40px;
    height: 60px;
    background-color: black;
    position: absolute;
    border-radius: 50%;
    transform: rotate(-70deg);
    left: 65px;
    bottom: 45px;
  }
}
.eyeball {
  border: 5px solid white;
  height: 40px;
  width: 40px;
  position: relative;
  top: 10px;
  left: 135px;
  border-radius: 50%;
}

@media screen and (max-width: 500px) {
  .eyeball {
    border: 2px solid white;
    height: 20px;
    width: 20px;
    position: relative;
    top: 5px;
    left: 67px;
    border-radius: 50%;
  }
}
.eyeball::before {
  content: "";
  display: block;
  border: 5px solid white;
  height: 40px;
  width: 40px;
  border-radius: 50%;
  position: absolute;
  left: 123px;
}
@media screen and (max-width: 500px) {
  .eyeball::before {
    content: "";
    display: block;
    border: 2px solid white;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    position: absolute;
    left: 62px;
  }
}
.highlight {
  height: 10px;
  width: 10px;
  background-color: white;
  position: relative;
  top: -20px;
  left: 145px;
  border-radius: 50%;
}
@media screen and (max-width: 500px) {
  .highlight {
    height: 5px;
    width: 5px;
    background-color: white;
    position: relative;
    top: -8px;
    left: 72px;
    border-radius: 50%;
  }
}
.highlight::before {
  content: "";
  display: block;
  height: 10px;
  width: 10px;
  background-color: white;
  position: relative;
  top: 6px;
  left: 127px;
  border-radius: 50%;
}
@media screen and (max-width: 500px) {
  .highlight::before {
    content: "";
    display: block;
    height: 5px;
    width: 5px;
    background-color: white;
    position: relative;
    top: 2px;
    left: 66px;
    border-radius: 50%;
  }
}
.face {
  border-top-left-radius: 50% 60%;
  border-top-right-radius: 50% 60%;
  border-bottom-left-radius: 41% 42%;
  border-bottom-right-radius: 41% 42%;
  border: 5px solid #006bb0;
  width: 350px;
  height: 250px;
  position: relative;
  left: 40px;
  top: -100px;
  box-shadow: 0 0 0 5px yellow, 0 0 0 10px black, 0 0 0 15px green,
    0 0 0 20px red;
}
@media screen and (max-width: 500px) {
  .face {
    border-top-left-radius: 50% 60%;
    border-top-right-radius: 50% 60%;
    border-bottom-left-radius: 41% 42%;
    border-bottom-right-radius: 41% 42%;
    border: 2px solid #006bb0;
    width: 175px;
    height: 125px;
    position: relative;
    left: 20px;
    top: -60px;
    box-shadow: 0 0 0 2px yellow, 0 0 0 5px black, 0 0 0 7px green,
      0 0 0 10px red;
  }
}
.ear {
  width: 80px;
  height: 100px;
  border-radius: 50%;
  position: relative;
  left: 15px;
  top: -430px;
  background-color: black;
}
@media screen and (max-width: 500px) {
  .ear {
    width: 40px;
    height: 50px;
    border-radius: 50%;
    position: relative;
    left: 7px;
    top: -218px;
    background-color: black;
  }
}
.ear::before {
  content: "";
  display: block;
  width: 80px;
  height: 100px;
  border-radius: 50%;
  position: relative;
  left: 315px;
  background-color: black;
}
@media screen and (max-width: 500px) {
  .ear::before {
    content: "";
    display: block;
    width: 40px;
    height: 50px;
    border-radius: 50%;
    position: relative;
    left: 160px;
    background-color: black;
  }
}
.handleft {
  width: 80px;
  height: 150px;
  position: relative;
  top: -300px;
  left: -70px;
  border-radius: 40px;
  transform: rotate(35deg);
  background-color: black;
  z-index: -10;
}
@media screen and (max-width: 500px) {
  .handleft {
    width: 40px;
    height: 75px;
    position: relative;
    top: -150px;
    left: -35px;
    border-radius: 20px;
    transform: rotate(35deg);
    background-color: black;
    z-index: -10;
  }
}
.handleft::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  border: 30px solid;
  position: relative;
  left: 24px;
  border-color: white white transparent transparent;
}
@media screen and (max-width: 500px) {
  .handleft::before {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    border: 15px solid;
    position: relative;
    left: 12px;
    border-color: white white transparent transparent;
  }
}
.handright {
  width: 80px;
  height: 170px;
  position: relative;
  top: -500px;
  left: 420px;
  border-radius: 40px 40px 0 80px;
  transform: rotate(45deg);
  background-color: black;
}
@media screen and (max-width: 500px) {
  .handright {
    width: 40px;
    height: 85px;
    position: relative;
    top: -250px;
    left: 210px;
    border-radius: 20px 20px 0 40px;
    transform: rotate(45deg);
    background-color: black;
  }
}
.handright::before {
  content: "";
  display: block;
  width: 25px;
  height: 40px;
  background-color: red;
  position: relative;
  top: 20px;
  left: 18px;
  border-radius: 16px 16px 0 25px;
  transform: rotate(-15deg);
}
@media screen and (max-width: 500px) {
  .handright::before {
    content: "";
    display: block;
    width: 12px;
    height: 20px;
    background-color: red;
    position: relative;
    top: 10px;
    left: 9px;
    border-radius: 8px 8px 0 12px;
    transform: rotate(-15deg);
  }
}
.handright::after {
  content: "";
  display: block;
  width: 25px;
  height: 40px;
  background-color: red;
  position: relative;
  top: -20px;
  left: 35px;
  border-radius: 16px 16px 25px 0px;
  transform: rotate(15deg);
}
@media screen and (max-width: 500px) {
  .handright::after {
    content: "";
    display: block;
    width: 12px;
    height: 20px;
    background-color: red;
    position: relative;
    top: -10px;
    left: 17px;
    border-radius: 16px 16px 25px 0px;
    transform: rotate(15deg);
  }
}
.foot {
  width: 100px;
  height: 120px;
  position: relative;
  top: -400px;
  left: 60px;
  border-radius: 35px 55px 20px 35px;
  background-color: black;
}
@media screen and (max-width: 500px) {
  .foot {
    width: 50px;
    height: 60px;
    position: relative;
    top: -200px;
    left: 30px;
    border-radius: 18px 27px 10px 18px;
    background-color: black;
  }
}
.foot::before {
  content: "";
  display: block;
  width: 100px;
  height: 120px;
  position: relative;
  left: 200px;
  border-radius: 55px 35px 35px 20px;
  background-color: black;
}
@media screen and (max-width: 500px) {
  .foot::before {
    content: "";
    display: block;
    width: 50px;
    height: 60px;
    position: relative;
    left: 100px;
    border-radius: 58px 18px 17px 10px;
    background-color: black;
  }
}`;

const player = {
  id: undefined,
  time: 100,
  n: 1,
  ui: {
    demo: document.querySelectorAll("#demo")[0],
    demo2: document.querySelectorAll("#demo2")[0],
  },

  init: () => {
    player.play();
    player.ui.demo.innerHTML = string.substring(0, player.n);
    player.ui.demo2.innerText = string.substring(0, player.n);
    player.bindEvent();
  },

  events: {
    "#btnPause": "pause", // "#btnPause": player.pause,这种方法不可以，因为player对象还没有声明出来，其内部的对象不能引用player这个对象，但是函数可以，以为函数声明时并没有执行，执行的时候player对象已经构建好了
    "#btnPlay": "play", // "#btnPlay": player.play,
    "#btnSlow": "slow", // "#btnSlow": player.slow,
    "#btnNormal": "normal", // "#btnNormal": player.normal,
    "#btnFast": "fast", // "#btnFast": player.fast,
  },

  bindEvent: () => {
    for (let key in player.events) {
      if (player.events.hasOwnProperty(key)) {
        const value = player.events[key];
        document.querySelector(key).onclick = player[value];
      }
    }
  },

  run: () => {
    player.n += 1;
    if (player.n > string.length) {
      window.clearInterval(player.id);
      return;
    }
    player.ui.demo.innerHTML = string.substring(0, player.n);
    player.ui.demo2.innerText = string.substring(0, player.n);
    player.ui.demo2.scrollTop = 99999;
  },
  play: () => {
    player.id = setInterval(player.run, player.time);
  },
  pause: () => {
    window.clearInterval(player.id);
  },
  slow: () => {
    player.pause();
    player.time = 300;
    player.play();
  },

  normal: () => {
    player.pause();
    player.time = 100;
    player.play();
  },

  fast: () => {
    player.pause();
    player.time = 0;
    player.play();
  },
};

player.init();
